//package com.lancoo.ccas52.monitoring;
//
//import cn.hutool.json.JSONUtil;
//import com.lancoo.ccas52.service.YunBasicService;
//import com.rabbitmq.client.Channel;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.amqp.core.Message;
//import org.springframework.amqp.rabbit.annotation.RabbitHandler;
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
//
//import javax.annotation.Resource;
//import java.io.IOException;
//
///**
// * @ClassName RabbitMQConsumer
// * @Description 监听基础平台
// * @Author quin
// * @Date 2023/3/17 14:23
// */
////@Component
//@Slf4j
//public class RabbitMQConsumer {
//
//    @Resource
//    private YunBasicService yunBasicService;
//
//    @RabbitHandler
//    @RabbitListener(queues = "E31")
//    public void termMessageListener(String json, Channel channel, Message message) {
//        int flag = 0;
//
//        log.info("接收到消息={}", json);
//        RabbitMessage rabbitMessage = JSONUtil.toBean(json, RabbitMessage.class);
//        try {
//            if ("000_EDIT_TERM".equals(rabbitMessage.getMessageTypeCode())) {
//                //判断是否是新学期
//                //获取相关数据
//                yunBasicService.syncTeachingClassToBasic(1, "", "", "");
//                Thread.sleep(60000);
//
//                //同步课程
//                yunBasicService.syncScheduleToBasic(1, "", "", "");
//
//                flag = 1;
//            }
//        } catch (Exception e) {
//            e.printStackTrace();
//            log.error("通过RabbitMQ失败触发！" + e.getMessage());
//            flag = 2;
//        } finally {
//            if (flag == 1) {
//                try {
//                    channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
//                } catch (IOException e) {
//                    log.error(e.toString());
//                }
//            }
//        }
//
//    }
//}
